#!/bin/bash

rootfs_dir=/home/pbb3/qemu-busybox-test/rootfs-xfce
cross_tool_path=/usr/arm-linux-gnueabihf

Iinclude_dir+=" -I$cross_tool_path/include -I$rootfs_dir/include"

Llibs_dir+=" -L$cross_tool_path/lib -L$rootfs_dir/lib"
Llibs_dir+=" -L$rootfs_dir/lib/glib-2.0"

Llibs+=" -lffi -lgio-2.0 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lz"

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export CC=${CROSS_COMPILE}gcc

export LDFLAGS=${Llibs_dir}
export LIBS=$Llibs

export PKG_CONFIG_PATH=${rootfs_dir}/lib/pkgconfig:${PKG_CONFIG_PATH}

./configure --host=arm-linux-gnueabihf --prefix=$rootfs_dir
make -j64
make -j64 install

unset CC
unset CFLAGS
unset LDFLAGS
unset LIBS
unset CPPFLAGS
unset CPP
unset PKG_CONFIG
unset PKG_CONFIG_PATH
unset PKG_CONFIG_LIBDIR
unset GLIB_CFLAGS
unset GLIB_LIBS
